package com._520it.crm.service.impl;

import com._520it.crm.domain.Institute;
import com._520it.crm.mapper.InstituteMapper;
import com._520it.crm.page.PageResult;
import com._520it.crm.query.InstituteQueryObject;
import com._520it.crm.service.IInstituteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;

@Service
public class InstituteServiceImpl implements IInstituteService {
	@Autowired
	private InstituteMapper instituteMapper;
	public void insert(Institute record) {
		instituteMapper.insert(record);
	}

	public List<Institute> selectAll() {
		return instituteMapper.selectAll();
	}

	@Override
	public Institute selectByPrimaryKey(Long id) {
		return instituteMapper.selectByPrimaryKey(id);
	}

	@Override
	public void updateByPrimaryKey(Institute ins) {
		instituteMapper.updateByPrimaryKey(ins);
	}

	@Override
	public PageResult queryPage(InstituteQueryObject qo) {
		Integer count = instituteMapper.queryPageCount(qo);
		if(count <= 0){
			return new PageResult(0, Collections.EMPTY_LIST);
		}
		List<Institute> result =  instituteMapper.queryPageData(qo);
		return new PageResult(count, result);
	}

}